package com.richard.main.ui.adapter

import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentPagerAdapter
import com.richard.base.route.KsRouterHelper
import me.yokeyword.fragmentation.SupportFragment

/**
 ***************************************
 * 项目名称:Giggle
 * @Author wuzhiguo
 * 邮箱：wuzhiguo@ksjgs.com
 * 创建时间: 2020/7/26     1:00 PM
 * 用途:
 ***************************************
 */
class MainPagerAdapter(fm : FragmentManager) : FragmentPagerAdapter(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) {

    companion object {
        const val VIEW_FIRST = 0
        const val VIEW_SECOND = 1
        const val VIEW_SIZE = 2
    }

    private var homeFragment : SupportFragment = KsRouterHelper.getHomeRecFragment()
    private var personFragment: SupportFragment = KsRouterHelper.getMineFragment()


//    private var homeFragment : HomeRecFragment = HomeRecFragment.newInstance()
//    private var personFragment: HomeMineFragment = HomeMineFragment.newInstance()


    override fun getItem(position : Int) : Fragment{
        when (position) {
            VIEW_FIRST -> {
                return homeFragment;
            }
            VIEW_SECOND -> {
                return personFragment;
            }
        }
        return homeFragment
    }


    override fun getCount() : Int {
        return VIEW_SIZE;
    }

}